home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Texto y fuentes / TwentyFourPointScreenFonts / TwentyFourPointScreenFonts.cs next >
Encoding:
Text File  |  2002-04-24  |  2.2 KB  |  57 lines

  1. //---------------------------------------------------------
  2. // TwentyFourPointScreenFonts.cs ⌐ 2001 by Charles Petzold
  3. //---------------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class TwentyFourPointScreenFonts: PrintableForm
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new TwentyFourPointScreenFonts());
  13.      }
  14.      public TwentyFourPointScreenFonts()
  15.      {
  16.           Text = "Fuentes de pantalla de veinticuatro puntos";
  17.      }
  18.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  19.      {
  20.           Brush  brush     = new SolidBrush(clr);
  21.           float  y         = 0;
  22.           Font   font;
  23.           string strFamily = "Times New Roman";
  24.  
  25.           font = new Font(strFamily, 24);
  26.           grfx.DrawString("Sin GraphicsUnit, 24 puntos", font, brush, 0, y);
  27.           y += font.GetHeight(grfx);
  28.  
  29.           font = new Font(strFamily, 24, GraphicsUnit.Point);
  30.           grfx.DrawString("GraphicsUnit.Point, 24 unidades", font, brush, 0, y);
  31.           y += font.GetHeight(grfx);
  32.  
  33.           font = new Font(strFamily, 1/ 3f, GraphicsUnit.Inch);
  34.           grfx.DrawString("GraphicsUnit.Inch, 1/3 unidad", font, brush, 0, y);
  35.           y += font.GetHeight(grfx);
  36.  
  37.           font = new Font(strFamily, 25.4f / 3, GraphicsUnit.Millimeter);
  38.           grfx.DrawString("GraphicsUnit.Millimeter, 25.4/3 unidades", 
  39.                           font, brush, 0, y);
  40.           y += font.GetHeight(grfx);
  41.  
  42.           font = new Font(strFamily, 100, GraphicsUnit.Document);
  43.           grfx.DrawString("GraphicsUnit.Document, 100 unidades", 
  44.                           font, brush, 0, y);
  45.           y += font.GetHeight(grfx);
  46.  
  47.           font = new Font(strFamily, grfx.DpiY / 3, GraphicsUnit.Pixel);
  48.           grfx.DrawString("GraphicsUnit.Pixel, " + grfx.DpiY / 3 + " unidades",
  49.                           font, brush, 0, y);
  50.           y += font.GetHeight(grfx);
  51.  
  52.           font = new Font(strFamily, grfx.DpiY / 3, GraphicsUnit.World);
  53.           grfx.DrawString("GraphicsUnit.World, " + grfx.DpiY / 3 + " unidades", 
  54.                           font, brush, 0, y);
  55.      }
  56. }
  57.